import axios from "axios";
import advList from "../views/advList.ejs";
export default function(){
	return (req,res)=>{
		res.render(advList());
		// formdata:
		// const formdata = new FormData();
		// 1- set
		// formdata.set("userName","wangwu");
		// 2- get
		// console.log(formdata.get("userName"));// wangwu
		
		// formdata.set("userName","one");
		// formdata.set("userName","two");
		// console.log(formdata.get("userName"));// two
		
		// 3- append
		// formdata.append("userName","one");
		// formdata.append("userName","two");
		// console.log(formdata.get("userName"));// one
		// console.log(formdata.getAll("userName"));// ["one","two"]
		// formdata.delete("userName");
		// console.log(formdata.get("userName"));// null
		// console.log(formdata.getAll("userName"));// []
		
		
		document.querySelector("#adv-save").onclick = function(){
			// 结合表单使用:将表单元素作为FormData构造函数的参数
			// const formdata = new FormData(document.advForm);
			// console.log(formdata.get("advType"))
			
			// 不封装
			const formdata = new FormData(document.advForm);
			axios.post("/bang/advList",formdata).then(value=>{
				console.log("成功回调",value.data)
			})
		}
		
		
	}
}